package com.zzyl.config;

import com.zzyl.intercept.JwtTokenInterceptor;
import com.zzyl.intercept.MobileInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvc高级配置类
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private MobileInterceptor mobileInterceptor;
    @Autowired
    private JwtTokenInterceptor jwtTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //小程序的拦截器
        registry.addInterceptor(mobileInterceptor)
                .excludePathPatterns("/customer/user/login")
                .addPathPatterns("/customer/**");


        registry.addInterceptor(jwtTokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/customer/**"
                        ,"/common/**"
                        ,"/security/login"
                        ,"/security/logout"
                        ,"/*-swagger/**"
                        ,"/swagger-resources"
                        ,"/v2/api-docs"
                        ,"/ws/**"
                        ,"/error");


    }

}
